package com.xuelang.pipeline.app.resource;

import com.xuelang.pipeline.app.resource.impl.DynamicNamespaceServiceFallbackImpl;
import com.xuelang.pipeline.app.resource.request.NamespaceListRequest;
import com.xuelang.pipeline.app.resource.request.NamespaceMainRequest;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.resource.dto.NamespaceDTO;
import feign.Headers;
import feign.RequestLine;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;

import jakarta.validation.Valid;
import java.net.URI;
import java.util.List;

/**
 * 动态命名空间服务接口
 *
 * @author xiwen.zxg
 * @since 2024/5/28
 */
@FeignClient(name = "dynamic-namespace-service", fallbackFactory = DynamicNamespaceServiceFallbackImpl.class)
public interface DynamicNamespaceService {

    /**
     * 获取命名空间列表
     *
     * @param uri
     * @param namespaceListRequest
     * @return
     */
    @RequestLine("POST /get/namespace/list")
    @Headers("Content-Type: application/json")
    ApiResult<List<NamespaceDTO>> list(URI uri, @RequestBody @Valid NamespaceListRequest namespaceListRequest);

    /**
     * 创建命名空间
     *
     * @param uri
     * @param namespaceMainRequest
     * @return
     */
    @RequestLine("POST /create/namespace")
    @Headers("Content-Type: application/json")
    ApiResult<Boolean> create(URI uri, @RequestBody @Valid NamespaceMainRequest namespaceMainRequest);

    /**
     * 删除命名空间
     *
     * @param uri
     * @param namespaceMainRequest
     * @return
     */
    @RequestLine("POST /delete")
    @Headers("Content-Type: application/json")
    ApiResult<Boolean> delete(URI uri, @RequestBody @Valid NamespaceMainRequest namespaceMainRequest);
}
